#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QModelIndex>
#include <QToolBar>
#include <QMap>
#include <QModelIndex>

#include "Card.h"
#include "CardInfo.h"
#include "currentitemobserver.h"

#include "ui_mainwindow.h"

class QAction;
class QTreeView;
class QWidget;
class QListWidget;
class QTimer;
class QShortcut;
class TreeModel;
class PersistentDialog;
class MuCustomShortcuts;

class Deck;

class ReviewInfo : public QWidget
{

	public:
		explicit ReviewInfo(QWidget* pParent);
		//ReviewInfo(const ReviewInfo&) {} //Qt prohibits copying constructors and assignment operators
		//ReviewInfo& operator=(const ReviewInfo&){return *this;}
		~ReviewInfo();

		CardInfo							m_reviewCardInfo; //TODO: possibly this method should also be a pointer type
		QModelIndex						m_initialReviewIndex;
		//CardRenderer::Side				m_sideShowingNext;
		QTimer*							m_pReviewBranchTimer;

		Q_OBJECT

	private:
		Q_DISABLE_COPY(ReviewInfo) //http://developer.qt.nokia.com/doc/qt-4.8/qobject.html#Q_DISABLE_COPY
};

class MainWindow : public QMainWindow, private Ui::MainWindow
{
		Q_OBJECT

	public:
		MainWindow(QWidget *parent = 0);
		~MainWindow();

	public slots:
		void								updateActions();

		//protected:

		//bool eventFilter(QObject *, QEvent *);

	private 	slots:
		void								insertLeaf();
		void								insertRow();
		void								removeRow();
		//void								diplayCard(const QModelIndex &);
		void								cut();
		void								paste();
		void								pasteInto();
		void								multiSelectionPressed();
		void								convertSelectionToCards();
		void								find();
		void								setShortcutsEnabled(bool);
		void								pauseBranch();
		void								invertItem();
		void								persistentModeClicked();
		void								enterPersistentMode();
		void								persistentDialogReturned(int);
		void								showAnswerColumn();
		void								onPersistentDialogAnswerDisplayed();
		void								deselectAll();
		void								printDueDate();
		void								on_actionPreferences_triggered();
		void								on_actionImport_Data_triggered();

		void								enterQuestionEditMode();
		void								exitQuestionEditMode();
		void								enterAnswerEditMode();
		void								exitAnswerEditMode();
		void								beginEditFocusedArea();
		void								endEditFocusedArea();

		//generated by the designer
		void								on_actionNew_triggered();
		void								on_actionOpen_triggered();
		void								on_actionSave_As_triggered();

		void								onCurrentChanged(QModelIndex,QModelIndex);

		void on_actionAbout_triggered();

protected:

		void								closeEvent(QCloseEvent *);

	private:

		void								setupShortcuts();
		void								setupTheme();

	private:

		QModelIndex						getIndex() const;
		TreeModel*						getTreeModel() const;

		QToolBar*						m_pToolbar;
		//CardRenderer*					m_pCardRenderer;
		CardInfo							m_currentlyActiveCard;
		Deck*							m_pDeck;
		QMap<QString, QShortcut*>			m_shortcuts;
		QTimer*							m_pUpdateTimer;

		// This timer kicks in when user is in persistent mode but
		// there are no cards to review
		QTimer*							m_pReviewTimer;

		bool								m_persistentDialogIsShowing;
		CurrentItemObserver*			m_currentItemObserver;
		MuCustomShortcuts*				m_muShortcuts;
		QFont							m_documentFont;

};

#endif
